{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "a24b661f",
   "metadata": {},
   "source": [
    "<center><font size=5>姓名：冉成林   学号：20201120466   专业：电子科学与技术</font></center>"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "90b8bc67",
   "metadata": {},
   "source": [
    "<center><font size=6>Project #2</font></center>"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f8082ee3",
   "metadata": {},
   "source": [
    "<center><font size=5>Understanding root and equation systems</font></center>"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7d7e4d91",
   "metadata": {},
   "source": [
    "<div align=center> <img src=\"https://pic2.zhimg.com/80/v2-e5b098e4dc6892147ecd6b89965e2e1f_720w.jpg?source=1940ef5c\" width=\"800\"></div>"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fce64509",
   "metadata": {},
   "source": [
    "<center><font size=4>日期：2022.4.12</font></center>"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f7f6e735",
   "metadata": {},
   "source": [
    "##  "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "146a2833",
   "metadata": {},
   "source": [
    "##  "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "82fa6886",
   "metadata": {},
   "source": [
    "# 1.Root #"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "26862a13",
   "metadata": {},
   "source": [
    "### 1.1 Fix point iteration（不动点迭代法）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "id": "e605ad0d",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "id": "aa98de49",
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "id": "3a894cb4",
   "metadata": {},
   "outputs": [],
   "source": [
    "def func1(x):\n",
    "    return 3-7/(x+3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "id": "261a7353",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1.4142135628279473\n"
     ]
    }
   ],
   "source": [
    "array1=np.zeros((1000,4))\n",
    "i=0\n",
    "d=0\n",
    "array1[0,0]=100\n",
    "arrayx=array1[:,0]\n",
    "arrayy=array1[:,1]\n",
    "while True:\n",
    "    array1[i,1]=func1(array1[i,0])\n",
    "    if abs(array1[i,0]-array1[i,1])<0.000000001:\n",
    "        break\n",
    "    array1[i+1,0]=array1[i,1]\n",
    "    i=i+1\n",
    "print(array1[i,1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "id": "0a852e8b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1.4142135621496286\n"
     ]
    }
   ],
   "source": [
    "array2=np.zeros((10000,4))\n",
    "i=0\n",
    "xold=1\n",
    "xnew=0\n",
    "while True:\n",
    "    xnew=func1(xold)\n",
    "    d=abs(xold-xnew)\n",
    "    array2[i,:]=[xold,xnew,i,d]\n",
    "    i=i+1\n",
    "    if d<0.000000001:\n",
    "        break\n",
    "    xold=xnew\n",
    "ilist=array2[:i,2]\n",
    "xnewlist=array2[:i,1]\n",
    "print(xnew)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "id": "92f5e1f8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Text(0, 0.5, 'Xnew')"
      ]
     },
     "execution_count": 86,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZYAAAEOCAYAAACqzTG4AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAAh70lEQVR4nO3dfZRcdZ3n8fenH/IcSEjniQQIBORBkBDbCAsi6KiBcQ2s6wCDEBEXZ2fYkT3urJz1KO5xzow4o+46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NZfmOObGMzmPACZKOTf+3eylw96B17gauTEc7nQm8PnDKWSppG+7fA89GxFeHWWdeuh6SlpF85ltLHNdUSdMHlkk6f9cNWq3sx6vAsP+TzON4FbgbWJkurwTuGmKd0XwXMyVpOfAZ4EMR0TXMOqP5zLOOq7BP7uJhXq/sxyv1e8BzEdE6VGWpj9cIvw3l+Y6VYkTCePwjGcX0G5LREp9Ny/4I+KN0WcDfpvVPA81liOkcklPUp4C16d+Fg+K6FlhPMrLjEeDflSGu49LXezJ97Yo4XunrTiFJFIcXlJX9eJEktnagh+R/iFcDs4AHgRfSxyPSdY8E7h3pu1jiuF4kaXMf+I7dNDiu4T7zEsf1D+l35ymSH775lXC80vJbBr5TBeuW83gN99tQlu+YL+liZmaZclOYmZllyonFzMwy5cRiZmaZcmIxM7NMObGYmVmmnFjMKpiSqy2HpI/lHYvZaDmxmJlZpjyPxayCSaojuXR5T0T05R2P2Wg4sZiZWabcFGZWwdzHYtXIicXMzDLlxGJmZplyYjEzs0w5sZiZWaacWMzMLFNOLGZmliknFjMzy5QTi5mZZcqJxczMMuVLupiZWaZ8xmJmZplyYjEzs0w5sZiZWaacWMzMLFNOLGZmliknFjMzy5QTi5mZZcqJxczMMuXEYmZmmfr/gt3JhmRpe3cAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(ilist,xnewlist)\n",
    "plt.xlabel(\"i\",fontsize=18)\n",
    "plt.ylabel(\"Xnew\",fontsize=18)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "79f0b64d",
   "metadata": {},
   "source": [
    "### 1.2 Newton method（牛顿法）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "id": "48d674c2",
   "metadata": {},
   "outputs": [],
   "source": [
    "def func2(x):\n",
    "    return x-(x**3+x-1)/(x**2*3+1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "id": "3e6089e7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.6823278038280193\n"
     ]
    }
   ],
   "source": [
    "xl=np.zeros((50,2))\n",
    "i=0\n",
    "xl[0,0]=100\n",
    "il=np.zeros((1,50))\n",
    "while True:\n",
    "    xl[i,1]=func2(xl[i,0])\n",
    "    d=abs(xl[i,0]-xl[i,1])\n",
    "    il[0,i]=i+1\n",
    "    if d<0.000000001:\n",
    "        break\n",
    "    xl[i+1,0]=xl[i,1]\n",
    "    i=i+1\n",
    "print(xl[i,1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "id": "3b2ba75e",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Text(0, 0.5, 'Xnew')"
      ]
     },
     "execution_count": 89,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYYAAAEOCAYAAACNY7BQAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAAjkUlEQVR4nO3deXiV9Z338ff3ZCNhC4Ek7ASQJUFFMQqIiEjS2k3tZu2iVG3x6djWto5Te3Wedmb6TOuMMzpOZzojY0WqjlZtq7bTOiKgKGULCojse8KWsEMCZPs+f5wjciBADpzkPjnn87quXPe575zlIxA/+d3L7zZ3R0RE5AOhoAOIiEhiUTGIiEgUFYOIiERRMYiISBQVg4iIREkPOkA89OrVy4uKioKOISLSoSxdunSPu+efuj0piqGoqIiKioqgY4iIdChmtrWl7dqVJCIiUVQMIiISRcUgIiJRVAwiIhJFxSAiIlFUDCIiEkXFICIiUVK6GN5cV8Mv3tgQdAwRkYSS0sUwf8MeHpm1jsPHGoKOIiKSMFK6GMqKC2locuat2xN0FBGRhJHSxTBmYC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3bCv5VtA3YCB939tWBTnVGhu++E8C8uQEHAec7mTuBPQYc4lZndCGx39+VBZzmD4cBEM1tkZm+a2ZXxeFMVQ5yZWRfgN8B33P1Q0Hk+YGafBKrdfWnQWc4iHRgD/Ie7Xw7UEuzuj9NE9tPfBAwG+gKdzewrwabq2Mzsh4R3xT4TdJaTmVkO8EPgR0FnOYt0oAfh3df3A8+bWUu3R46JiiGOzCyDcCk84+6/DTrPKSYAN5rZFuA54HozezrYSKepAqrc/YOR1ouEiyKRlAGb3b3G3RuA3wJXB5zpTHabWR+AyDIuuxniycymAp8EvuyJd1HVUMK/ACyP/Nz0B94xs96BpopWBfzWwxYT3htwwQfIVQxxEmnpXwKr3f3hoPOcyt1/4O793b2I8MHSOe6eUL/puvsuoNLMRkQ2TQFWBRipJduAcWaWE/k7n0KCHSA/ySvA1MjjqcDLAWY5jZndAHwfuNHd64LOcyp3f8/dC9y9KPJzUwWMifw7TRQvAdcDmNlwIJM4zAarYoifCcBthH8TXxb5+njQoTqgbwHPmNkK4DLgp8HGiRYZzbwIvAO8R/hnKPBpE8zsWWABMMLMqszsLuBBoNzM1hM+q+bBBMv3b0BXYFbk5+U/g8p3lowJ4wz5ngCGRE5hfQ6YGo+Rl6bEEBGRKBoxiIhIFBWDiIhEUTGIiEgUFYOIiERRMYiISBQVg0gbMrPrIrNyfjXoLCKtpWIQEZEouo5BpA2ZWYjw1agN7t4UdB6R1lAxiIhIFO1KEmlDOsYgHZGKQUREoqgYREQkiopBRESiqBhERCSKikFERKKoGEREJIqKQUREoqgYREQkiopBRESiaEoMERGJohGDiIhEUTGIiEgUFYOIiERRMYiISBQVg4iIRFExiIhIFBWDiIhEUTGIiEgUFYOIiET5/3DkE0ZqJ0MmAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(il[0,:i],xl[:i,1])\n",
    "plt.xlabel(\"i\",fontsize=18)\n",
    "plt.ylabel(\"Xnew\",fontsize=18)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ac81aea1",
   "metadata": {},
   "source": [
    "### 1.3 Bisection（二分法）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 90,
   "id": "97e2f88e",
   "metadata": {},
   "outputs": [],
   "source": [
    "def func5 (x):\n",
    "    return x*x-2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 91,
   "id": "a3d3b280",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "根号2的值大约为： 1.4142135623730947\n"
     ]
    }
   ],
   "source": [
    "i=0\n",
    "x=np.zeros((100,2))\n",
    "y=np.zeros((100,2))\n",
    "x[0,:]=([0,3])\n",
    "i3=np.zeros((100,1))\n",
    "while True:\n",
    "    i3[i]=i\n",
    "    a=x[i,0]/2+x[i,1]/2\n",
    "    d=func5(a)\n",
    "    if d>0:\n",
    "        y[i,:]=[x[i,0],a]\n",
    "    if d<0:\n",
    "        y[i,:]=[a,x[i,1]]\n",
    "    x[i+1,:]=y[i,:]\n",
    "    if (x[i,1]-x[i,0])<0.000000000000001:\n",
    "        break\n",
    "    i=i+1\n",
    "    i3[i+1]=i\n",
    "print(\"根号2的值大约为：\",x[i,0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "id": "ed87edbb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Text(0, 0.5, 'Xright or Xleft')"
      ]
     },
     "execution_count": 92,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYoAAAEOCAYAAACXX1DeAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAAedklEQVR4nO3de5xdZX3v8c93LskEMkOE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Q/MkzQF+KmkI3MuqSYknQasj4ilkk7MuZzRckJErJV0MHCLpMdHuwC3KBJrgFkFn2cCa3OqZTQ9L2k6QPq+Pud6qkZSK0lIXB8RP0k31+31DoqIDcBvSPqj6vF6TwDeI+kZklvE75D0L9TntQIQEWvT9/XAT0lulY/q9TooEvcBcyUdJmkCcAawKOeaRsMi4Kz057OAm3KspWqUNB2+ByyPiG8V7KrX652WtiSQNAl4F/A4dXi9EfFXETEzIjpJ/j+9LSI+Sh1eK4Ck/SW1D/4MvBt4hFG+Xj+ZnZJ0Ksm9z2bg6oj4Sr4VVZekG4ETSaYnfh64BPgZ8CNgNrAK+GBEFHd4jzuS3grcATzM7vvYf03ST1GP1/tGkg7NZpJ//P0oIr4k6SDq8HoHpbeePhcRp9XrtUp6FUkrApKughsi4iujfb0OCjMzy+RbT2ZmlslBYWZmmRwUZmaWyUFhZmaZHBRmZpbJQWE2SiSdKCkknZ13LWaVcFCYmVkmP0dhNkokNQETgL50biazccFBYWZmmXzryWyUuI/CxisHhZmZZXJQmJlZJgeFmZllclCYmVkmB4WZmWVyUJiZWSYHhZmZZXJQmJlZJgeFmZll8hQeZmaWyS0KMzPL5KAwM7NMDgozM8vkoDAzs0wOCjMzy+SgMDOzTA4KMzPL5KAwM7NMDgozM8v0/wEx0v1DMF7whQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(i3[:i,0],x[:i,1])\n",
    "plt.plot(i3[:i,0],x[:i,0])\n",
    "plt.xlabel(\"i\",fontsize=18)\n",
    "plt.ylabel(\"Xright or Xleft\",fontsize=18)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6a113c99",
   "metadata": {},
   "source": [
    "### 1.4 Secant（割线法）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 93,
   "id": "4c675d08",
   "metadata": {},
   "outputs": [],
   "source": [
    "def func3(y,x):\n",
    "    return y-(y**3+y-1)*(y-x)/(y**3+y-1-x**3-x+1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "id": "0ce9be84",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.6823278038280184\n"
     ]
    }
   ],
   "source": [
    "array3=np.zeros((50,4))\n",
    "i=0\n",
    "array3[0,0]=0\n",
    "array3[0,1]=100\n",
    "while True:\n",
    "    array3[i,2]=func3(array3[i,1],array3[i,0])\n",
    "    d=abs(array3[i,0]-array3[i,1])\n",
    "    array3[i+1,0]=array3[i,1]\n",
    "    array3[i+1,1]=array3[i,2]\n",
    "    d=abs(array3[i,0]-array3[i,1])\n",
    "    if d<0.000000001:\n",
    "        break\n",
    "    array3[i,3]=i+1\n",
    "    i=i+1\n",
    "print(array3[i,1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "id": "f9835382",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Text(0, 0.5, 'Xnew')"
      ]
     },
     "execution_count": 95,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAY0AAAEOCAYAAAB1g0unAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAAam0lEQVR4nO3de5BcZ3nn8e/T3XPRTB+h20y3kCxLxtNNHBZi7yzY8SYBHO9SCUGurWLXCRDFcZWqtggYik3WbCpLUrspvBWKxAkbqlTmolooE8qhYhdFCF7ZxiFxDPKFxbYYjfBVtqQZ2bI8GllzffaPPjNqjUfS6Zmeec/p/n2qVKfPpfs8NNC/Oed9z/uauyMiIpJELnQBIiKSHQoNERFJTKEhIiKJKTRERCQxhYaIiCRWCF3AStq0aZNv3749dBkiIpnyyCOPHHf3vsX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iIokpNEREJDGFhoiIJKbQEBGRxBQaIiKSmEJDREQSU2iIiEhiCg0REUns/wPp8oCK+Cr36AAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(array3[:i,3],array3[:i,1])\n",
    "plt.xlabel(\"i\",fontsize=18)\n",
    "plt.ylabel(\"Xnew\",fontsize=18)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "df819d1a",
   "metadata": {},
   "source": [
    "## 1.5 个人关于方程求根不同的方法思考"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "90753e70",
   "metadata": {},
   "source": [
    "### 1.不动点迭代法：\n",
    "### 不动点迭代法的迭代方程比较好找，但是不动点迭代法收敛速度较慢，由于迭代方程不止一个，选择不正确的迭代方程可能会导致迭代的发散。\n",
    "### 2.牛顿法：\n",
    "### 牛顿法可二次收敛，收敛速度极快，但如果遇到不好求导的方程可能就会有一些麻烦。\n",
    "### 3.二分法：\n",
    "### 二分法的逻辑简单，但起点不能随便取，收敛速度也不是很快。\n",
    "### 4.割线法：\n",
    "### 割线法相较于牛顿法不需要求导，且可超线性收敛，但在使用前需要预估初始值。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "aabc6fad",
   "metadata": {},
   "source": [
    "#  Equation systems"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f3cc10cb",
   "metadata": {},
   "source": [
    "## 2.1 Gauss elimination"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5bec3011",
   "metadata": {},
   "source": [
    "## 求解方程组为："
   ]
  },
  {
   "cell_type": "markdown",
   "id": "90fa2354",
   "metadata": {},
   "source": [
    "$$\\begin{cases}\n",
    "-0.027×X1+0.067×X2+0.515×X3=-2.111\\\\\n",
    "0.508×X1+0.21×X2+0.653×X3=-0.053\\\\\n",
    "0.271×X1-1×X2+0.867×X3=2.215\\\\\n",
    "\\end{cases}\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8e85104c",
   "metadata": {},
   "source": [
    "## 矩阵A为:"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ba54aa38",
   "metadata": {},
   "source": [
    "$$\\begin{bmatrix}\n",
    "-0.027&0.067&0.515\\\\\n",
    "0.508&0.21&0.653\\\\\n",
    "0.271& -1&0.867\\\\\n",
    "\\end{bmatrix}$$"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bb5112c8",
   "metadata": {},
   "source": [
    "## 矩阵BB为："
   ]
  },
  {
   "cell_type": "markdown",
   "id": "33952b90",
   "metadata": {},
   "source": [
    "$$\\begin{bmatrix}\n",
    "-2.111\\\\\n",
    "-0.053\\\\\n",
    "0.215\\\\\n",
    "\\end{bmatrix}$$"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f5276da6",
   "metadata": {},
   "source": [
    "## 矩阵X为："
   ]
  },
  {
   "cell_type": "markdown",
   "id": "47139d83",
   "metadata": {},
   "source": [
    "$$\\begin{bmatrix}\n",
    "X1\\\\\n",
    "X2\\\\\n",
    "X3\\\\\n",
    "\\end{bmatrix}$$"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bdc07080",
   "metadata": {},
   "source": [
    "## 原方程组变为矩阵形式为：\n",
    "<center><font size=5>AX=BB</font></center>"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "51bbf3b0",
   "metadata": {},
   "source": [
    "## 消元法代码"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b483ab8b",
   "metadata": {},
   "source": [
    "### Step 1: elimination（消元）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 96,
   "id": "0db5626a",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 97,
   "id": "2be6ffdb",
   "metadata": {},
   "outputs": [],
   "source": [
    "A=np.array([[-0.027,  0.067,  0.515],\n",
    "       [ 0.508,  0.21 ,  0.653],\n",
    "       [ 0.271, -1.   ,  0.867]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 98,
   "id": "a7c356a8",
   "metadata": {},
   "outputs": [],
   "source": [
    "BB=np.array([[-2.111],\n",
    "          [-0.053],\n",
    "          [0.215]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "id": "e88256e8",
   "metadata": {},
   "outputs": [],
   "source": [
    "n=3\n",
    "B1=A.copy()\n",
    "B2=BB[:,0].copy()\n",
    "for i in range(0,n):\n",
    "    for j in range (i+1,n):\n",
    "        C= -B1[j,i]/B1[i,i]\n",
    "        B2[j]=B2[j]+C*B2[i]\n",
    "        for k in range (i,n):\n",
    "            B1[j,k]=B1[j,k]+B1[i,k]*C"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "id": "b488db7b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-0.027,  0.067,  0.515],\n",
       "       [ 0.508,  0.21 ,  0.653],\n",
       "       [ 0.271, -1.   ,  0.867]])"
      ]
     },
     "execution_count": 100,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "A"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 101,
   "id": "d958de31",
   "metadata": {},
   "outputs": [],
   "source": [
    "U=np.triu(A,0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 102,
   "id": "56de58d7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-0.027,  0.067,  0.515],\n",
       "       [ 0.   ,  0.21 ,  0.653],\n",
       "       [ 0.   ,  0.   ,  0.867]])"
      ]
     },
     "execution_count": 102,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "U"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "id": "2ab14555",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-0.027,  0.067,  0.515],\n",
       "       [ 0.   ,  1.471, 10.343],\n",
       "       [ 0.   ,  0.   ,  8.34 ]])"
      ]
     },
     "execution_count": 103,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "B1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "id": "d4c80c22",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ -2.111, -39.771, -29.831])"
      ]
     },
     "execution_count": 104,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "B2"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b41181ef",
   "metadata": {},
   "source": [
    "### Old version"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 113,
   "id": "156f4d48",
   "metadata": {},
   "outputs": [],
   "source": [
    "#A1 = A.copy()\n",
    "#b1 = b.copy()\n",
    "#print(A1)\n",
    "#for i in range(0, n+1):\n",
    "#    for j in range(i + 1, n):\n",
    "#        C = - A[j, i] / A[i, i]\n",
    "#        b1[j] = b1[j] + C * b1[i]\n",
    "#        for k in range(i, n):\n",
    "#            A1[j, k] = A[j, k] + C * A[i, k]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3f58bebd",
   "metadata": {},
   "source": [
    "### New version"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 115,
   "id": "c4509aa9",
   "metadata": {},
   "outputs": [],
   "source": [
    "#A1 = A.copy()\n",
    "#b1 = b.copy()\n",
    "#print(A1)\n",
    "#for i in range(0, n+1):\n",
    "#    for j in range(i + 1, n):\n",
    "#        C = - A1[j, i] / A1[i, i]\n",
    "#        b1[j] = b1[j] + C * b1[i]\n",
    "#        for k in range(i, n):\n",
    "#            A1[j, k] = A1[j, k] + C * A1[i, k]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0cdbe166",
   "metadata": {},
   "source": [
    "### Question: what are the differences of old and new version?"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "590da721",
   "metadata": {},
   "source": [
    "## 答：新版和旧版算出的A1一样，A也都没有改变，但是计算的途径却有所不同。虽然旧版A1复制了A的元素且有新的地址，但还是引用的A的旧地址在计算，并赋值给了A1。但新版是引用A1新的地址进行计算，并且对A1进行变换。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9888f8a7",
   "metadata": {},
   "source": [
    "### Step 2: calculation x（回带求值）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "id": "05f3680c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0., 0., 0.])"
      ]
     },
     "execution_count": 105,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x=np.zeros(3)\n",
    "x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 106,
   "id": "192d6546",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3 行\n",
      "2 行\n",
      "3 列\n",
      "1 行\n",
      "2 列\n",
      "3 列\n"
     ]
    }
   ],
   "source": [
    "for i in range(n-1,-1,-1):\n",
    "    sumx=0\n",
    "    print(i+1,\"行\")\n",
    "    for j in range(i+1,n):\n",
    "        print(j+1,\"列\")\n",
    "        sumx=sumx+x[j]*B1[i,j]\n",
    "    x[i]=(B2[i]-sumx)/B1[i,i]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 107,
   "id": "37716e6a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 5.274, -1.887, -3.577])"
      ]
     },
     "execution_count": 107,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7772c133",
   "metadata": {},
   "source": [
    "### Step 3：verification（验证）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "id": "ac8bc2c6",
   "metadata": {},
   "outputs": [],
   "source": [
    "inverseB3=np.linalg.inv(A)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "id": "71a934e9",
   "metadata": {},
   "outputs": [],
   "source": [
    "x1=inverseB3@BB"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 110,
   "id": "40ec903e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-0.027,  0.067,  0.515],\n",
       "       [ 0.508,  0.21 ,  0.653],\n",
       "       [ 0.271, -1.   ,  0.867]])"
      ]
     },
     "execution_count": 110,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "A"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 111,
   "id": "cdaefa78",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 5.274],\n",
       "       [-1.887],\n",
       "       [-3.577]])"
      ]
     },
     "execution_count": 111,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 112,
   "id": "0064e1ca",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 5.274, -1.887, -3.577])"
      ]
     },
     "execution_count": 112,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "033493bf",
   "metadata": {},
   "source": [
    "### step 4: My experience"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cf457f85",
   "metadata": {},
   "source": [
    "## 1：在用高斯消元法求解线性方程组时，要注意所取矩阵的浮点位数，若全为整数，计算过程中的矩阵元素也都为整数，最后计算的结果误差就会巨大。所以最好在取矩阵时在小数点后加适当的零，有利于得到正确的结果。\n",
    "## 2：在进行高斯消元法前，要明确消元逻辑，确定for循环的层数，以及循环的上下限。\n",
    "## 3：高斯消元法有局限性，一旦遇到奇异矩阵就很麻烦了。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f7712d23",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
